package com.example.tests;

import org.testng.annotations.Test;
import com.example.pages.AddMoviePage;
import com.example.pages.FilmPage;

public class CreateEditRecordTest extends TestBase {

	@Test
	public void testAddRecord() {
		goToMainPage().logInwithValidCredentials(login, oldPass).addMovie()
				.fillFormWithDefault().logOut();
	}

	@Test
	public void testEditRecord() {
		AddMoviePage edit = goToMainPage()
				.logInwithValidCredentials(login, oldPass)
				.selectFilmForEdit(filmTestTitle).openForEdit();
		edit.IMBD.clear();
		edit.IMBD.sendKeys(newIMDB);
		edit.title.clear();
		edit.title.sendKeys(newTestTitle);
		FilmPage submitForm = edit.submitForm();
		AddMoviePage openForEdit = submitForm.openForEdit();
		openForEdit.verifyIfFilmChangesSaved(newTestTitle, newIMDB);
		openForEdit.logOut();
	}
}